﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using NRemedy;
using NRemedy.CodeGenerate;

namespace Wicresoft.NRemedy.VS10Addin.UI
{
    public class CustomGetARFieldFilterDelegate : IGetARFieldFilterDelegate
    {
        List<string> _IncludeFields;

        public CustomGetARFieldFilterDelegate(List<string> IncludeFields)
        {
            _IncludeFields = IncludeFields;
 
        }

        public ARFieldFilterDelegate getARFieldFilterDelegate()
        {
            return new ARFieldFilterDelegate(filterIsDataFieldOrReservedField);
        }

        private bool filterIsDataFieldOrReservedField(BMC.ARSystem.Field field)
        {

            //if (!field.IsCoreField && field.IsDataField())
            //issue about ARRegularForm core field
            if (field.IsDataField())
            {
                if (_IncludeFields != null && _IncludeFields.FirstOrDefault(f => f == field.Name) != null)
                {
                    return true;
                }
 
            }

            return false;
        }

    }
}
